package cn.yuanqiao.archive.Identify.domain;

import cn.yuanqiao.common.utils.DateUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Destroy {
    /**
     * 主键
     */
    private Long destroyId;
    /**
     * 标题
     */
    private String destroyName;
    /**
     * 申请人
     */
    private String destroyUser;
    private Long destroyUserId;
    /**
     * 申请部门
     */
    private String destroyDept;
    private Long destroyDeptId;
    /**
     * 状态 0=未办结 1=审批中 2=已办结 -1 退回(不同意)
     */
    private Integer status;
    /**
     * 申请日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    private Date destroyDate;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 备注
     */
    private String destroyRemark;

    /**
     * 流程ID
     */
    private Long activitiId;

    /**
     * 销毁清册
     */
    private String destroyListPath;

    /**
     * 租户编码
     */

    private String tenantCode;

    /*是否存入了全宗卷*/
    private String isqzj;

    public String getIsqzj() {
        return isqzj;
    }

    public void setIsqzj(String isqzj) {
        this.isqzj = isqzj;
    }

    public Long getDestroyId() {
        return destroyId;
    }

    public void setDestroyId(Long destroyId) {
        this.destroyId = destroyId;
    }

    public String getDestroyName() {
        return destroyName;
    }

    public void setDestroyName(String destroyName) {
        this.destroyName = destroyName;
    }

    public String getDestroyUser() {
        return destroyUser;
    }

    public void setDestroyUser(String destroyUser) {
        this.destroyUser = destroyUser;
    }

    public Long getDestroyUserId() {
        return destroyUserId;
    }

    public void setDestroyUserId(Long destroyUserId) {
        this.destroyUserId = destroyUserId;
    }

    public String getDestroyDept() {
        return destroyDept;
    }

    public void setDestroyDept(String destroyDept) {
        this.destroyDept = destroyDept;
    }

    public Long getDestroyDeptId() {
        return destroyDeptId;
    }

    public void setDestroyDeptId(Long destroyDeptId) {
        this.destroyDeptId = destroyDeptId;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getDestroyDate() {
        return destroyDate;
    }

    public void setDestroyDate(Date destroyDate) {
        this.destroyDate = destroyDate;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getDestroyRemark() {
        return destroyRemark;
    }

    public void setDestroyRemark(String destroyRemark) {
        this.destroyRemark = destroyRemark;
    }

    public Long getActivitiId() {
        return activitiId;
    }

    public void setActivitiId(Long activitiId) {
        this.activitiId = activitiId;
    }

    public String getDestroyListPath() {
        return destroyListPath;
    }

    public void setDestroyListPath(String destroyListPath) {
        this.destroyListPath = destroyListPath;
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    @Override
    public String toString() {
        return "Destroy{" +
                "destroyId=" + destroyId +
                ", destroyName='" + destroyName + '\'' +
                ", destroyUser='" + destroyUser + '\'' +
                ", destroyUserId=" + destroyUserId +
                ", destroyDept='" + destroyDept + '\'' +
                ", destroyDeptId=" + destroyDeptId +
                ", status=" + status +
                ", destroyDate=" + destroyDate +
                ", createTime=" + createTime +
                ", destroyRemark='" + destroyRemark + '\'' +
                ", activitiId=" + activitiId +
                ", destroyListPath='" + destroyListPath + '\'' +
                ", tenantCode='" + tenantCode + '\'' +
                '}';
    }

    public Map<String, Object> toProcessMap() {
        Map<String, Object> map = new HashMap<>();

        // 使用反射获取实体类的字段信息
        Class<?> clazz = this.getClass();
        Field[] fields = clazz.getDeclaredFields();

        try {
            // 遍历所有字段，获取字段名和字段值，并存储到 Map 中
            for (Field field : fields) {
                if (field.getType().isAssignableFrom(Date.class)){
                    field.setAccessible(true); // 设置字段可访问，即使是私有字段也可以获取值
                    String fieldName = field.getName();
                    Object fieldValue = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, (Date) field.get(this)); // 获取字段的值
                    map.put(fieldName, fieldValue);
                    continue;
                }
                field.setAccessible(true); // 设置字段可访问，即使是私有字段也可以获取值
                String fieldName = field.getName();
                Object fieldValue = field.get(this); // 获取字段的值
                map.put(fieldName, fieldValue);
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        return map;
    }
}
